home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Textension / Include / TSMTextension.h < prev   
Encoding:
C/C++ Source or Header  |  1994-04-21  |  4.4 KB  |  164 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TSMTextension.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Essam Zaky
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>      1/4/94    EZ        clean up
  13.          <1>      1/4/94    EZ        first checked in
  14.  
  15. */
  16.  
  17. #ifndef _TSMTextension_
  18. #define _TSMTextension_
  19.  
  20. #ifndef _ToolBoxDump_
  21. #include "ToolBoxDump.h"
  22. #endif
  23.  
  24. #ifndef _Textension_
  25. #include "Textension.h"
  26. #endif
  27.  
  28.  
  29. #ifndef __TEXTSERVICES__
  30. #include <TextServices.h>
  31. #endif
  32.  
  33. #ifndef _TSMRun_
  34. #include "TSMRun.h"
  35. #endif
  36. //***************************************************************************************************
  37.  
  38. /*
  39. -Segments:
  40.     -InOut
  41.     -TSMTextension (resident)
  42. */
  43. //***************************************************************************************************
  44.  
  45. //cosnt and types for "fHiliteObjectsData"
  46.  
  47. struct THiliteObjectData {
  48.     CRunObject* hiliteObj;
  49.     long hiliteFace;
  50. };
  51. //***************************************************************************************************
  52.  
  53. //TKeyDownParams.flags constants (returned from CalcKeyDownParams)
  54. const TKeyDownFlags kTSMKeyDown = 1 << 11; //••other TKeyDownParams fields are undefined
  55. //***************************************************************************************************
  56.  
  57. class CTSMTextension : public CTextension {
  58.  
  59. public:
  60. //-------
  61.     static OSErr TSMTextensionStart(CTextensionScrap* localScrap = nil);
  62.     static void TSMTextensionTerminate();
  63.     
  64.     static char CanUseTSM() {return fCanUseTSM;}
  65.     //if false a "CTextension" can be created instead of "CTSMTextension"
  66.  
  67.     static Boolean IsTSMEvent(EventRecord* event);
  68.     //should be called in place of "TSMEvent"
  69.     
  70.     CTSMTextension();
  71.     
  72.     OSErr ITSMTextension(GrafPtr textPort, TTextensionHandlers* handlers, TSize sizeInfo = kLargeSize);
  73.     
  74.     //•override
  75.     virtual void Free();
  76.     
  77.     #ifdef txtnNever
  78.     virtual void ChangeContext(long contextId, Boolean turnSelOn =true);
  79.     #endif
  80.     
  81.     virtual void Activate(Boolean activ, Boolean turnSelOn =true);
  82.  
  83.     virtual void SetSelectionRange(const TOffsetRange& selRange
  84.                                                             , Boolean forceOn = true, Boolean updateKeyScript=true);
  85.     
  86.     virtual Boolean Click(const EventRecord* event, TClickCommandInfo* clickCommandInfo
  87.                                                 , ClickLoopProcPtr clickProc = nil, void* clickProcData = nil);
  88.     
  89.     virtual void CalcKeyDownParams(const EventRecord* event, Boolean bufferKeys, TKeyDownParams* params);
  90.     
  91.     virtual OSErr ReplaceRange(long rangeStart, long rangeEnd, TReplaceParams* replaceParams, Boolean invisible = true);
  92.  
  93.     virtual OSErr UpdateRangeRuns(const TOffsetRange* theRange, const TAttrObjModifier* modifier
  94.                                                             , Boolean invisible=false);
  95.     //overriden sine our inline hole can have only 1 qd face, size, ..
  96.     
  97.     //•own
  98.     Boolean HasActiveInputArea(long* inlineAreaStart, long* inlineAreaEnd);
  99.     
  100.     void FixActiveInputArea();
  101.     
  102.     OSErr UpdateActiveInputEvent(uPtr activText, long activSize, long fixLen,
  103.                                                             TextRangeArrayPtr updateRng,
  104.                                                             TextRangeArrayPtr hiliteRng);
  105.     
  106.     void Pos2OffsetEvent(Point thePt, Boolean dragging
  107.                                             , short* where, TOffset* charOffset);
  108.     /*
  109.     -thePt is in local coord
  110.     -*where is set to "kTSMOutsideOfBody", "kTSMInsideOfBody" or "kTSMInsideOfActiveInputArea"
  111.     -charOffset->offset is < 0  if *where is "kTSMOutsideOfBody"
  112.     */
  113.     
  114.     OSErr Offset2PosEvent(long offset, Point* thePt
  115.                                             , short* lineHite, short* lineAscent
  116.                                             , CRunObject** inlineRun);
  117.     /*
  118.     -returned err is "noErr", "errOffsetInvalid" or "errOffsetIsOutsideView"
  119.     */
  120.     
  121.     #ifdef txtnDebug
  122.     void ShowDebugInfo();
  123.     #endif
  124.     
  125. protected:
  126. //----------
  127.     //•override
  128.     virtual CRunObject* UpdatePendingRun();
  129.     
  130. private:
  131. //--------
  132. static char fCanUseTSM;
  133. static char fTSMInitialized;
  134. static CObjectsRanges* fHiliteRanges;
  135.  
  136. TSMDocumentID fTSMDocId;
  137. long fActivStart; //if < 0 ==> no activ inline area
  138. long fActivEnd;
  139.  
  140. CRunObject* fInlineRun;
  141.  
  142. THiliteObjectData fHiliteObjectsData[kCountTSMFaces];
  143. char fHiliteObjectsReady;
  144.  
  145.     CRunObject* HiliteStyle2RunObj(short hiliteStyle);
  146.     
  147.     OSErr CalcInlineRunObjects(TextRangeArrayPtr hiliteRng, CObjectsRanges* hiliteObjects, long* caretPos);
  148.                                         
  149.     void HiliteEvent(CObjectsRanges* newHilites);
  150.     
  151.     OSErr FixActiveInputAreaEvent(uPtr fixText, long fixSize);
  152.  
  153.     void InlineAreaFixed_AdjustRange(long* rangeStart, long* rangeEnd);
  154.     
  155.     #ifdef txtnDebug
  156.     void DumpUpdateData(long activSize, long fixLen
  157.                                             , TextRangeArrayPtr updateRng
  158.                                             , TextRangeArrayPtr hiliteRng);
  159.     #endif
  160. };
  161. //***************************************************************************************************
  162.  
  163. #endif
  164.